﻿@using ERP.WebUI
@model PermissionButtonModel
@{
    ViewBag.Title = "SetButton";
}

<div id="content-body" class="row-fluid">
    <div class="span22">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon"><i class="icon-edit"></i></span>
                <h5>设置按钮</h5>
            </div>
            <div class="widget-content nopadding">
                <form id="modal-content" class="form-horizontal search-form">
                    <h2>@Model.ModuleName</h2>

                    @Html.HiddenFor(t => t.ModuleId)

                    @Html.CheckBoxListFor(t => t.SelectedButtonList, DisplayDirection.Horizon, new { style = "display:inline-block;width:500px;margin:0 10px;" }, new { style = "display:inline-block;width:120px;" })
                    <div class="form-actions form-operate">
                        <input type="submit" value="确定" class="btn btn-primary" id="model-submit">
                        <input type="button" value="返回" onclick="history.back(-1)" class="btn btn-primary">
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
        $(function () {
            $("#model-submit").click(function () {
                var $form = $("#modal-content");
                if (!$form.valid()) {
                    return;
                }
                var actionUrl = "@Url.Action("SetButton")";
                var data = $form.serialize();
                $.ajax({
                    type: "POST",
                    async: false,
                    url: actionUrl,
                    data: data,
                    success: function (data) {
                        //判断返回值，若为Object类型，即操作成功
                        var result = ((typeof data == 'object') && (data.constructor == Object));
                        alertMessage(1, data.Message, 5);
                        var url = "@Url.Action("Index")";
                        location.href = url;
                    }
                });
            });
        });
    </script>
}
